require "proto/vip/message/ReqVipInfoMessage"
require "proto/vip/message/ReqFetchVipRewardMessage"
require "proto/noble/message/ReqSendNobleInfoMessage"
require "proto/noble/message/ReqBuyNobleMessage"


vipHandler = vipHandler or {};
G.serverData = G.serverData or {};

function vipHandler.GetVipInfoMsg(msg)
    if msg.state == 0 then
        logicMgr.VipManager.resVipInfoMsg(msg)
        FireEvent(Config.EventType.Fresh_CostRedDot);
    end
end

function vipHandler.GetVipDrawRewardMsg(msg)
    if msg.state == 0 then
        logicMgr.VipManager.getFetchReward(msg.items);
        FireEvent(Config.EventType.Fresh_CostRedDot);
    end
end

function vipHandler.GetPrivilegeInfoMsg(msg)
    if msg.state == 0 then
        logicMgr.VipManager.setPrivilegeInfo(msg.endTime, msg.times);
    end
end

function vipHandler.reqGetVipInfo()
    local req = ReqVipInfoMessage.New();
    sendReqMessage(req);
end

function vipHandler.reqGetVipDrawReward(id)
    local req = ReqFetchVipRewardMessage.New();
    req.vipLv = tonumber(id);
    sendReqMessage(req);
end

function vipHandler.reqGetPrivilegeInfo()
    local req = ReqSendNobleInfoMessage.New();
    sendReqMessage(req);
end

function vipHandler.reqBuyPrivilege(id)
    local req = ReqBuyNobleMessage.New();
    req.nobleId = tonumber(id);
    sendReqMessage(req);
end